package com.gopay.bis.pab.ebank.impl;


import com.gopay.bis.pab.ebank.operation.PabB2cQueryOrder;
import com.gopay.common.domain.bank.BaseMessage;
import com.gopay.common.domain.bank.pab.ebank.PabB2cMessage;
import com.gopay.common.domain.bank.pab.ebank.PabOrderMessageRes;
import com.gopay.common.domain.bank.pab.ebank.PabQueryOrdersMessageRes;
import com.gopay.common.exception.GopayException;
import com.gopay.remote.bank.ICertHelper;
import com.gopay.remote.bank.businesses.BankService;

public class PabB2cBankServiceImpl implements BankService {

	private ICertHelper b2cCerthelper;
	private PabB2cQueryOrder b2cQueryOrder;
	 /**
     * 签名
     * 
	 * @param BaseMessage
	 * @return Object
	 * @throws GopayException
     */
	public Object sign(BaseMessage msg) throws GopayException {
		String signMessage = "";
		PabB2cMessage message = (PabB2cMessage) msg;
		signMessage = (String) b2cCerthelper.sign(message);
		return signMessage;
	}
	/**
     * 验签
     * 
	 * @param BaseMessage
	 * @return Object
	 * @throws GopayException
     */
	public Object verify(BaseMessage msg) throws GopayException {
		boolean flag = false;
		PabOrderMessageRes message = (PabOrderMessageRes) msg;
		flag = (Boolean) b2cCerthelper.verify(message);
		return flag;
	}

	public Object query(Object obj) throws GopayException {
		BaseMessage baseMessage = (BaseMessage) obj;
		String signStr = b2cCerthelper.sign(baseMessage);
		baseMessage.setSignMessage(signStr);
		PabQueryOrdersMessageRes pabQueryRes = b2cQueryOrder.query(baseMessage);
		return pabQueryRes;
	}

	public ICertHelper getB2cCerthelper() {
		return b2cCerthelper;
	}

	public void setB2cCerthelper(ICertHelper b2cCerthelper) {
		this.b2cCerthelper = b2cCerthelper;
	}

	public PabB2cQueryOrder getB2cQueryOrder() {
		return b2cQueryOrder;
	}

	public void setB2cQueryOrder(PabB2cQueryOrder b2cQueryOrder) {
		this.b2cQueryOrder = b2cQueryOrder;
	}

	@Override
	public Object dayend(Object obj) throws GopayException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object refund(Object obj) throws GopayException {
		// TODO Auto-generated method stub
		return null;
	}

}
